<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Document</title>
</head>
<body>
	<script type="text/javascript">
		function Node(data) {
			
			this.childs=new S.List();
			this.events = new S.Event();
			this.data = data;
			this.sid = S.guid();
			this.selected = false;
			
			if(this.data.children){
				this.leaf  = true;
				S.each(data.children, function(i,n) {
					var node= new S.Tree.Node(n);
					this.add(node);
				}.bind(this));
			}
		}
		
		Node.prototype={
			add:function(node){
				node.parent = this;
				this.childs.push(node);
			},
			remove:function(){
				this.childs.each(function(i,node){
					node.remove();
				});
				this.parent && this.parent.children.remove(this);
				$('#'+this.sid).remove();
			},
			expand:function(all){
				this.childs.each(function(i,node){
					$('#'+node.sid).show();
					if(all){
						node.exapnd(all);
					}
				});
			},
			find:function(id){
				var result=null;
				this.childs.each(function(i,node){
					if(S.isFunction(id) && id(node.data) || (node.sid == id)){
						result = node;
						return false;
					}
					result = node.find(id);
					if(result !=null){return false;}
				});
				return result;
			},
			getHtml:function(){
				var html = [];
				html.push('<li id="'+this.sid+'">'+this.data.text+'</li>');
				this.childs.each(function(i,node) {
					html.push(node.getHtml());
				});
				return html.join('');
			}
		};

		
		
		
		var  tree = new S.Tree({
			
		});
		tree.setData([]);
		tree.getSelectedItems();
		tree.selecte(id);
		tree.addNode(node);		
		tree.removeNode(id);
		tree.find(id);
		
		
		var node = new S.Tree.Node({});
		node.children();
		node.find(id);
		node.add(node);
		node.remove(id);
		node.isLeaf();
		node.getData();
		node.isSelected();
		node.selecte();
		node.getSId();
		
		
		
		
		
		
		var data = [{
			name:'',
			url:'',
			icon:'',
			children:[{
				
			}]
		}];
		
		var data = [{
			id:'',
			pid:1,
			name:'',
			open:true,
		},{
			
		}];
		
		
		
		
	</script>
</body>
</html>